package com.ruoyi.common.utils;

import java.util.Random;

public enum IOSVersionInfo {
    // iOS 15.x versions
    IOS_15_0("15.0", "1206.1.0", "Darwin 21.0.0"),
    IOS_15_1("15.1", "1216.0.0", "Darwin 21.0.0"),
    IOS_15_1_1("15.1.1", "1216.0.0", "Darwin 21.0.0"),
    IOS_15_2("15.2", "1220.1.0", "Darwin 21.1.0"),
    IOS_15_3("15.3", "1237.0.0", "Darwin 21.2.0"),
    IOS_15_3_1("15.3.1", "1237.0.0", "Darwin 21.2.0"),
    IOS_15_4("15.4", "1240.0.4", "Darwin 21.3.0"),
    IOS_15_4_1("15.4.1", "1240.0.4", "Darwin 21.3.0"),
    IOS_15_5("15.5", "1240.0.4", "Darwin 21.4.0"),
    IOS_15_6("15.6", "1240.0.4", "Darwin 21.5.0"),
    IOS_15_7("15.7", "1240.0.4", "Darwin 21.6.0"),

    // iOS 16.x versions
    IOS_16_0("16.0", "1335.0.0", "Darwin 22.0.0"),
    IOS_16_1("16.1", "1335.0.0", "Darwin 22.1.0"),
    IOS_16_2("16.2", "1335.0.0", "Darwin 22.2.0"),
    IOS_16_3("16.3", "1335.0.0", "Darwin 22.3.0"),
    IOS_16_4("16.4", "1335.0.0", "Darwin 22.4.0"),
    IOS_16_5("16.5", "1335.0.0", "Darwin 22.5.0"),

    // iOS 17.x versions
    IOS_17_0("17.0", "1390.0.0", "Darwin 23.0.0"),
    IOS_17_1("17.1", "1390.0.0", "Darwin 23.1.0"),
    IOS_17_2("17.2", "1390.0.0", "Darwin 23.2.0"),
    IOS_17_3("17.3", "1390.0.0", "Darwin 23.3.0");

    private final String iosVersion;
    private final String cfNetworkVersion;
    private final String darwinVersion;

    IOSVersionInfo(String iosVersion, String cfNetworkVersion, String darwinVersion) {
        this.iosVersion = iosVersion;
        this.cfNetworkVersion = cfNetworkVersion;
        this.darwinVersion = darwinVersion;
    }

    public String getIosVersion() {
        return iosVersion;
    }

    public String getCfNetworkVersion() {
        return cfNetworkVersion;
    }

    public String getDarwinVersion() {
        return darwinVersion;
    }

    public static IOSVersionInfo getByVersion(String version) {
        for (IOSVersionInfo info : IOSVersionInfo.values()) {
            if (info.getIosVersion().equalsIgnoreCase(version)) {
                return info;
            }
        }
        return null;
    }
    public static IOSVersionInfo getRandomVersion() {
        IOSVersionInfo[] versions = IOSVersionInfo.values();
        Random random = new Random();
        return versions[random.nextInt(versions.length)];
    }
}
